/*********************************************************************
	Rhapsody	: 7.6
	Login		: Ryszard
	Component	: DefaultComponent
	Configuration 	: DefaultConfig
	Model Element	: Lift
//!	Generated Date	: Wed, 23, Nov 2011 
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Lift.java
*********************************************************************/

package CargoLiftSystem;

//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;

//----------------------------------------------------------------------------
// CargoLiftSystem/Lift.java                                                                  
//----------------------------------------------------------------------------

//## package CargoLiftSystem 


//## class Lift 
public class Lift implements RiJStateConcept {
    
    public Reactive reactive;		//## ignore 
    
    protected int currentDirection;		//## attribute currentDirection 
    
    protected int currentFloor;		//## attribute currentFloor 
    
    protected Alarm itsAlarm;		//## link itsAlarm 
    
    protected AlarmBreakingDetector itsAlarmBreakingDetector;		//## link itsAlarmBreakingDetector 
    
    protected Controller itsController;		//## link itsController 
    
    protected Engine itsEngine;		//## link itsEngine 
    
    protected IndoorDisplay itsIndoorDisplay;		//## link itsIndoorDisplay 
    
    protected InnerDoor itsInnerDoor;		//## link itsInnerDoor 
    
    protected Lights itsLights;		//## link itsLights 
    
    protected LocationDetector itsLocationDetector;		//## link itsLocationDetector 
    
    protected ObstacleInDoorDetector itsObstacleInDoorDetector;		//## link itsObstacleInDoorDetector 
    
    protected OuterDoor itsOuterDoor;		//## link itsOuterDoor 
    
    protected OverloadDetector itsOverloadDetector;		//## link itsOverloadDetector 
    
    protected ScheduleApplication itsScheduleApplication;		//## link itsScheduleApplication 
    
    protected SmokeDetector itsSmokeDetector;		//## link itsSmokeDetector 
    
    //#[ ignore 
    public static final int RiJNonState=0;
    public static final int activeLift=1;
    public static final int state_4=2;
    public static final int mode=3;
    public static final int normalMode=4;
    public static final int alarmMode=5;
    public static final int state_3=6;
    public static final int processingNextScheduledAction=7;
    public static final int openingDoor=8;
    public static final int nextFloor=9;
    public static final int movingToNextFloor=10;
    public static final int moving=11;
    public static final int idle=12;
    public static final int changingDirection=13;
    public static final int activated=14;
    //#]
    protected int rootState_subState;		//## ignore 
    
    protected int rootState_active;		//## ignore 
    
    protected int state_4_subState;		//## ignore 
    
    protected int state_4_active;		//## ignore 
    
    protected int mode_subState;		//## ignore 
    
    protected int state_3_subState;		//## ignore 
    
    protected int state_3_active;		//## ignore 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public boolean isIn(int state) {
        return reactive.isIn(state);
    }
    
    //## statechart_method 
    public boolean isCompleted(int state) {
        return reactive.isCompleted(state);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  Lift(RiJThread p_thread) {
        reactive = new Reactive(p_thread);
        initRelations(p_thread);
    }
    
    /**
     * @param floorOfRequest
    */
    //## operation addRequestFromInside(int) 
    public void addRequestFromInside(int floorOfRequest) {
        //#[ operation addRequestFromInside(int) 
        //#]
    }
    
    //## operation cancelAllRequests() 
    public void cancelAllRequests() {
        //#[ operation cancelAllRequests() 
        //#]
    }
    
    //## operation getCurrentFloor() 
    public int getCurrentFloor() {
        //#[ operation getCurrentFloor() 
        return currentFloor;
        //#]
    }
    
    //## operation getDirection() 
    public int getDirection() {
        //#[ operation getDirection() 
        return currentDirection;
        //#]
    }
    
    //## operation hasCallForThisFloor() 
    public boolean hasCallForThisFloor() {
        //#[ operation hasCallForThisFloor() 
            if((itsScheduleApplication.hasCallForFloor(currentFloor))==true)
            	return true;
            else
            	return false;
        //#]
    }
    
    //## operation hasMoreFloorsToProcess() 
    public boolean hasMoreFloorsToProcess() {
        //#[ operation hasMoreFloorsToProcess() 
        boolean anyMore=false;
        boolean[] floors = itsScheduleApplication.getRequestedFloors();
        for(int i=0; i<floors.length; i++)
        {
         	if(floors[i] == true)
         	{
         		anyMore = true;
         		break;
         	}  	
        }
        
        if(anyMore == true)
          return true;
        else return false;
        //#]
    }
    
    //## operation hasMoreRequests() 
    public void hasMoreRequests() {
        //#[ operation hasMoreRequests() 
        //#]
    }
    
    //## operation moveToNextFloor() 
    public void moveToNextFloor() {
        //#[ operation moveToNextFloor() 
        //#]
    }
    
    //## operation needToChangeDirection() 
    public boolean needToChangeDirection() {
        //#[ operation needToChangeDirection() 
        boolean anyMore=false; 
        boolean[] floors = itsScheduleApplication.getRequestedFloors();
        if(currentDirection == true) //elevator goes up
        {
        	for(int i=currentFloor+1; i<floors.length; i++)
        	{
         	if(floors[i] == true)
         	{
         		anyMore = true;
         		break;
         	}  	
        }
        if(currentDirection == false)
        {
            for(int i=currentFloor-1; i>=0; i--)
        	{
         		if(floors[i] == true)
         		{
         		anyMore = true;
         		break;
         		}  	
             }
        
        }
        
        if(anyMore == false)	// no more floors in the same direction
          return true;
        else 
          return false;
        //#]
    }
    
    //## operation openDoor() 
    public void openDoor() {
        //#[ operation openDoor() 
        //#]
    }
    
    //## operation triggerAlarm() 
    public void triggerAlarm() {
        //#[ operation triggerAlarm() 
        //#]
    }
    
    //## auto_generated 
    public int getCurrentDirection() {
        return currentDirection;
    }
    
    //## auto_generated 
    public void setCurrentDirection(int p_currentDirection) {
        currentDirection = p_currentDirection;
    }
    
    //## auto_generated 
    public void setCurrentFloor(int p_currentFloor) {
        currentFloor = p_currentFloor;
    }
    
    //## auto_generated 
    public Alarm getItsAlarm() {
        return itsAlarm;
    }
    
    //## auto_generated 
    public void __setItsAlarm(Alarm p_Alarm) {
        itsAlarm = p_Alarm;
    }
    
    //## auto_generated 
    public void _setItsAlarm(Alarm p_Alarm) {
        if(itsAlarm != null)
            {
                itsAlarm.__setItsLift(null);
            }
        __setItsAlarm(p_Alarm);
    }
    
    //## auto_generated 
    public void setItsAlarm(Alarm p_Alarm) {
        if(p_Alarm != null)
            {
                p_Alarm._setItsLift(this);
            }
        _setItsAlarm(p_Alarm);
    }
    
    //## auto_generated 
    public void _clearItsAlarm() {
        itsAlarm = null;
    }
    
    //## auto_generated 
    public AlarmBreakingDetector getItsAlarmBreakingDetector() {
        return itsAlarmBreakingDetector;
    }
    
    //## auto_generated 
    public void __setItsAlarmBreakingDetector(AlarmBreakingDetector p_AlarmBreakingDetector) {
        itsAlarmBreakingDetector = p_AlarmBreakingDetector;
    }
    
    //## auto_generated 
    public void _setItsAlarmBreakingDetector(AlarmBreakingDetector p_AlarmBreakingDetector) {
        if(itsAlarmBreakingDetector != null)
            {
                itsAlarmBreakingDetector.__setItsLift(null);
            }
        __setItsAlarmBreakingDetector(p_AlarmBreakingDetector);
    }
    
    //## auto_generated 
    public AlarmBreakingDetector newItsAlarmBreakingDetector() {
        itsAlarmBreakingDetector = new AlarmBreakingDetector();
        itsAlarmBreakingDetector._setItsLift(this);
        return itsAlarmBreakingDetector;
    }
    
    //## auto_generated 
    public void deleteItsAlarmBreakingDetector() {
        itsAlarmBreakingDetector.__setItsLift(null);
        itsAlarmBreakingDetector=null;
    }
    
    //## auto_generated 
    public Controller getItsController() {
        return itsController;
    }
    
    //## auto_generated 
    public void __setItsController(Controller p_Controller) {
        itsController = p_Controller;
    }
    
    //## auto_generated 
    public void _setItsController(Controller p_Controller) {
        if(itsController != null)
            {
                itsController.__setItsLift(null);
            }
        __setItsController(p_Controller);
    }
    
    //## auto_generated 
    public void setItsController(Controller p_Controller) {
        if(p_Controller != null)
            {
                p_Controller._setItsLift(this);
            }
        _setItsController(p_Controller);
    }
    
    //## auto_generated 
    public void _clearItsController() {
        itsController = null;
    }
    
    //## auto_generated 
    public Engine getItsEngine() {
        return itsEngine;
    }
    
    //## auto_generated 
    public void __setItsEngine(Engine p_Engine) {
        itsEngine = p_Engine;
    }
    
    //## auto_generated 
    public void _setItsEngine(Engine p_Engine) {
        if(itsEngine != null)
            {
                itsEngine.__setItsLift(null);
            }
        __setItsEngine(p_Engine);
    }
    
    //## auto_generated 
    public void setItsEngine(Engine p_Engine) {
        if(p_Engine != null)
            {
                p_Engine._setItsLift(this);
            }
        _setItsEngine(p_Engine);
    }
    
    //## auto_generated 
    public void _clearItsEngine() {
        itsEngine = null;
    }
    
    //## auto_generated 
    public IndoorDisplay getItsIndoorDisplay() {
        return itsIndoorDisplay;
    }
    
    //## auto_generated 
    public void __setItsIndoorDisplay(IndoorDisplay p_IndoorDisplay) {
        itsIndoorDisplay = p_IndoorDisplay;
    }
    
    //## auto_generated 
    public void _setItsIndoorDisplay(IndoorDisplay p_IndoorDisplay) {
        if(itsIndoorDisplay != null)
            {
                itsIndoorDisplay.__setItsLift(null);
            }
        __setItsIndoorDisplay(p_IndoorDisplay);
    }
    
    //## auto_generated 
    public IndoorDisplay newItsIndoorDisplay(RiJThread p_thread) {
        itsIndoorDisplay = new IndoorDisplay(p_thread);
        itsIndoorDisplay._setItsLift(this);
        return itsIndoorDisplay;
    }
    
    //## auto_generated 
    public void deleteItsIndoorDisplay() {
        itsIndoorDisplay.__setItsLift(null);
        itsIndoorDisplay=null;
    }
    
    //## auto_generated 
    public InnerDoor getItsInnerDoor() {
        return itsInnerDoor;
    }
    
    //## auto_generated 
    public void __setItsInnerDoor(InnerDoor p_InnerDoor) {
        itsInnerDoor = p_InnerDoor;
    }
    
    //## auto_generated 
    public void _setItsInnerDoor(InnerDoor p_InnerDoor) {
        if(itsInnerDoor != null)
            {
                itsInnerDoor.__setItsLift(null);
            }
        __setItsInnerDoor(p_InnerDoor);
    }
    
    //## auto_generated 
    public InnerDoor newItsInnerDoor(RiJThread p_thread) {
        itsInnerDoor = new InnerDoor(p_thread);
        itsInnerDoor._setItsLift(this);
        return itsInnerDoor;
    }
    
    //## auto_generated 
    public void deleteItsInnerDoor() {
        itsInnerDoor.__setItsLift(null);
        itsInnerDoor=null;
    }
    
    //## auto_generated 
    public Lights getItsLights() {
        return itsLights;
    }
    
    //## auto_generated 
    public void __setItsLights(Lights p_Lights) {
        itsLights = p_Lights;
    }
    
    //## auto_generated 
    public void _setItsLights(Lights p_Lights) {
        if(itsLights != null)
            {
                itsLights.__setItsLift(null);
            }
        __setItsLights(p_Lights);
    }
    
    //## auto_generated 
    public Lights newItsLights() {
        itsLights = new Lights();
        itsLights._setItsLift(this);
        return itsLights;
    }
    
    //## auto_generated 
    public void deleteItsLights() {
        itsLights.__setItsLift(null);
        itsLights=null;
    }
    
    //## auto_generated 
    public LocationDetector getItsLocationDetector() {
        return itsLocationDetector;
    }
    
    //## auto_generated 
    public void __setItsLocationDetector(LocationDetector p_LocationDetector) {
        itsLocationDetector = p_LocationDetector;
    }
    
    //## auto_generated 
    public void _setItsLocationDetector(LocationDetector p_LocationDetector) {
        if(itsLocationDetector != null)
            {
                itsLocationDetector.__setItsLift(null);
            }
        __setItsLocationDetector(p_LocationDetector);
    }
    
    //## auto_generated 
    public LocationDetector newItsLocationDetector() {
        itsLocationDetector = new LocationDetector();
        itsLocationDetector._setItsLift(this);
        return itsLocationDetector;
    }
    
    //## auto_generated 
    public void deleteItsLocationDetector() {
        itsLocationDetector.__setItsLift(null);
        itsLocationDetector=null;
    }
    
    //## auto_generated 
    public ObstacleInDoorDetector getItsObstacleInDoorDetector() {
        return itsObstacleInDoorDetector;
    }
    
    //## auto_generated 
    public void __setItsObstacleInDoorDetector(ObstacleInDoorDetector p_ObstacleInDoorDetector) {
        itsObstacleInDoorDetector = p_ObstacleInDoorDetector;
    }
    
    //## auto_generated 
    public void _setItsObstacleInDoorDetector(ObstacleInDoorDetector p_ObstacleInDoorDetector) {
        if(itsObstacleInDoorDetector != null)
            {
                itsObstacleInDoorDetector.__setItsLift(null);
            }
        __setItsObstacleInDoorDetector(p_ObstacleInDoorDetector);
    }
    
    //## auto_generated 
    public ObstacleInDoorDetector newItsObstacleInDoorDetector() {
        itsObstacleInDoorDetector = new ObstacleInDoorDetector();
        itsObstacleInDoorDetector._setItsLift(this);
        return itsObstacleInDoorDetector;
    }
    
    //## auto_generated 
    public void deleteItsObstacleInDoorDetector() {
        itsObstacleInDoorDetector.__setItsLift(null);
        itsObstacleInDoorDetector=null;
    }
    
    //## auto_generated 
    public OuterDoor getItsOuterDoor() {
        return itsOuterDoor;
    }
    
    //## auto_generated 
    public void __setItsOuterDoor(OuterDoor p_OuterDoor) {
        itsOuterDoor = p_OuterDoor;
    }
    
    //## auto_generated 
    public void _setItsOuterDoor(OuterDoor p_OuterDoor) {
        if(itsOuterDoor != null)
            {
                itsOuterDoor.__setItsLift(null);
            }
        __setItsOuterDoor(p_OuterDoor);
    }
    
    //## auto_generated 
    public OuterDoor newItsOuterDoor() {
        itsOuterDoor = new OuterDoor();
        itsOuterDoor._setItsLift(this);
        return itsOuterDoor;
    }
    
    //## auto_generated 
    public void deleteItsOuterDoor() {
        itsOuterDoor.__setItsLift(null);
        itsOuterDoor=null;
    }
    
    //## auto_generated 
    public OverloadDetector getItsOverloadDetector() {
        return itsOverloadDetector;
    }
    
    //## auto_generated 
    public void __setItsOverloadDetector(OverloadDetector p_OverloadDetector) {
        itsOverloadDetector = p_OverloadDetector;
    }
    
    //## auto_generated 
    public void _setItsOverloadDetector(OverloadDetector p_OverloadDetector) {
        if(itsOverloadDetector != null)
            {
                itsOverloadDetector.__setItsLift(null);
            }
        __setItsOverloadDetector(p_OverloadDetector);
    }
    
    //## auto_generated 
    public OverloadDetector newItsOverloadDetector() {
        itsOverloadDetector = new OverloadDetector();
        itsOverloadDetector._setItsLift(this);
        return itsOverloadDetector;
    }
    
    //## auto_generated 
    public void deleteItsOverloadDetector() {
        itsOverloadDetector.__setItsLift(null);
        itsOverloadDetector=null;
    }
    
    //## auto_generated 
    public ScheduleApplication getItsScheduleApplication() {
        return itsScheduleApplication;
    }
    
    //## auto_generated 
    public void __setItsScheduleApplication(ScheduleApplication p_ScheduleApplication) {
        itsScheduleApplication = p_ScheduleApplication;
    }
    
    //## auto_generated 
    public void _setItsScheduleApplication(ScheduleApplication p_ScheduleApplication) {
        if(itsScheduleApplication != null)
            {
                itsScheduleApplication.__setItsLift(null);
            }
        __setItsScheduleApplication(p_ScheduleApplication);
    }
    
    //## auto_generated 
    public ScheduleApplication newItsScheduleApplication(RiJThread p_thread) {
        itsScheduleApplication = new ScheduleApplication(p_thread);
        itsScheduleApplication._setItsLift(this);
        return itsScheduleApplication;
    }
    
    //## auto_generated 
    public void deleteItsScheduleApplication() {
        itsScheduleApplication.__setItsLift(null);
        itsScheduleApplication=null;
    }
    
    //## auto_generated 
    public SmokeDetector getItsSmokeDetector() {
        return itsSmokeDetector;
    }
    
    //## auto_generated 
    public void __setItsSmokeDetector(SmokeDetector p_SmokeDetector) {
        itsSmokeDetector = p_SmokeDetector;
    }
    
    //## auto_generated 
    public void _setItsSmokeDetector(SmokeDetector p_SmokeDetector) {
        if(itsSmokeDetector != null)
            {
                itsSmokeDetector.__setItsLift(null);
            }
        __setItsSmokeDetector(p_SmokeDetector);
    }
    
    //## auto_generated 
    public SmokeDetector newItsSmokeDetector() {
        itsSmokeDetector = new SmokeDetector();
        itsSmokeDetector._setItsLift(this);
        return itsSmokeDetector;
    }
    
    //## auto_generated 
    public void deleteItsSmokeDetector() {
        itsSmokeDetector.__setItsLift(null);
        itsSmokeDetector=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsAlarmBreakingDetector = newItsAlarmBreakingDetector();
        itsIndoorDisplay = newItsIndoorDisplay(p_thread);
        itsInnerDoor = newItsInnerDoor(p_thread);
        itsLights = newItsLights();
        itsLocationDetector = newItsLocationDetector();
        itsObstacleInDoorDetector = newItsObstacleInDoorDetector();
        itsOuterDoor = newItsOuterDoor();
        itsOverloadDetector = newItsOverloadDetector();
        itsScheduleApplication = newItsScheduleApplication(p_thread);
        itsSmokeDetector = newItsSmokeDetector();
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        done &= itsIndoorDisplay.startBehavior();
        done &= itsInnerDoor.startBehavior();
        done &= itsScheduleApplication.startBehavior();
        done &= reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
            initStatechart();
        }
        
        //## statechart_method 
        public boolean isIn(int state) {
            if(state_3 == state)
                {
                    return isIn(activeLift);
                }
            if(state_3_subState == state)
                {
                    return true;
                }
            if(mode_subState == state)
                {
                    return true;
                }
            if(state_4 == state)
                {
                    return isIn(activeLift);
                }
            if(state_4_subState == state)
                {
                    return true;
                }
            if(rootState_subState == state)
                {
                    return true;
                }
            return false;
        }
        
        //## statechart_method 
        public boolean isCompleted(int state) {
            return true;
        }
        
        //## statechart_method 
        public void rootState_entDef() {
            {
                rootState_enter();
                rootStateEntDef();
            }
        }
        
        //## statechart_method 
        public int rootState_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(rootState_active == activeLift)
                {
                    res = activeLift_dispatchEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int activeLift_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(state_3_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(state_4_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = activeLift_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int state_4_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_4_active) {
                case normalMode:
                {
                    res = normalMode_takeEvent(id);
                }
                break;
                case alarmMode:
                {
                    res = alarmMode_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public int state_3_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_3_active) {
                case activated:
                {
                    res = activated_takeEvent(id);
                }
                break;
                case idle:
                {
                    res = idle_takeEvent(id);
                }
                break;
                case moving:
                {
                    res = moving_takeEvent(id);
                }
                break;
                case openingDoor:
                {
                    res = openingDoor_takeEvent(id);
                }
                break;
                case movingToNextFloor:
                {
                    res = movingToNextFloor_takeEvent(id);
                }
                break;
                case processingNextScheduledAction:
                {
                    res = processingNextScheduledAction_takeEvent(id);
                }
                break;
                case changingDirection:
                {
                    res = changingDirection_takeEvent(id);
                }
                break;
                case nextFloor:
                {
                    res = nextFloor_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## auto_generated 
        protected void initStatechart() {
            rootState_subState = RiJNonState;
            rootState_active = RiJNonState;
            state_4_subState = RiJNonState;
            state_4_active = RiJNonState;
            mode_subState = RiJNonState;
            state_3_subState = RiJNonState;
            state_3_active = RiJNonState;
        }
        
        //## statechart_method 
        public void activatedEnter() {
        }
        
        //## statechart_method 
        public int changingDirection_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = changingDirectionTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void changingDirection_exit() {
            popNullConfig();
            changingDirectionExit();
        }
        
        //## statechart_method 
        public void changingDirectionExit() {
        }
        
        //## statechart_method 
        public void changingDirection_enter() {
            pushNullConfig();
            state_3_subState = changingDirection;
            state_3_active = changingDirection;
            changingDirectionEnter();
        }
        
        //## statechart_method 
        public void idle_entDef() {
            idle_enter();
        }
        
        //## statechart_method 
        public void state_3EntDef() {
            activated_entDef();
        }
        
        //## statechart_method 
        public void state_3_entDef() {
            state_3_enter();
            state_3EntDef();
        }
        
        //## statechart_method 
        public void alarmMode_entDef() {
            alarmMode_enter();
        }
        
        //## statechart_method 
        public void mode_exit() {
            switch (mode_subState) {
                case normalMode:
                {
                    normalMode_exit();
                }
                break;
                case alarmMode:
                {
                    alarmMode_exit();
                }
                break;
                default:
                    break;
            }
            mode_subState = RiJNonState;
            modeExit();
        }
        
        //## statechart_method 
        public void state_4_exit() {
            if(state_4_subState == mode)
                {
                    mode_exit();
                }
            state_4_subState = RiJNonState;
            state_4Exit();
        }
        
        //## statechart_method 
        public void state_4EntDef() {
            mode_entDef();
        }
        
        //## statechart_method 
        public void idleEnter() {
        }
        
        //## statechart_method 
        public void moving_enter() {
            pushNullConfig();
            state_3_subState = moving;
            state_3_active = moving;
            movingEnter();
        }
        
        //## statechart_method 
        public void movingToNextFloorEnter() {
        }
        
        //## statechart_method 
        public int nextFloor_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = nextFloorTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void state_3_exit() {
            switch (state_3_subState) {
                case activated:
                {
                    activated_exit();
                }
                break;
                case idle:
                {
                    idle_exit();
                }
                break;
                case moving:
                {
                    moving_exit();
                }
                break;
                case openingDoor:
                {
                    openingDoor_exit();
                }
                break;
                case movingToNextFloor:
                {
                    movingToNextFloor_exit();
                }
                break;
                case processingNextScheduledAction:
                {
                    processingNextScheduledAction_exit();
                }
                break;
                case changingDirection:
                {
                    changingDirection_exit();
                }
                break;
                case nextFloor:
                {
                    nextFloor_exit();
                }
                break;
                default:
                    break;
            }
            state_3_subState = RiJNonState;
            state_3Exit();
        }
        
        //## statechart_method 
        public void movingExit() {
        }
        
        //## statechart_method 
        public int state_3_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int activeLift_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int activatedTakeliftIsDown() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            activated_exit();
            idle_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void activated_exit() {
            activatedExit();
        }
        
        //## statechart_method 
        public void nextFloorExit() {
        }
        
        //## statechart_method 
        public void idle_exit() {
            idleExit();
        }
        
        //## statechart_method 
        public void movingToNextFloor_exit() {
            movingToNextFloorExit();
        }
        
        //## statechart_method 
        public void alarmModeEnter() {
        }
        
        //## statechart_method 
        public void normalModeExit() {
        }
        
        //## statechart_method 
        public void modeExit() {
        }
        
        //## statechart_method 
        public void activeLiftExit() {
        }
        
        //## statechart_method 
        public void movingEnter() {
        }
        
        //## statechart_method 
        public void movingToNextFloorExit() {
        }
        
        //## statechart_method 
        public void movingToNextFloor_enter() {
            state_3_subState = movingToNextFloor;
            state_3_active = movingToNextFloor;
            movingToNextFloorEnter();
        }
        
        //## statechart_method 
        public void movingToNextFloor_entDef() {
            movingToNextFloor_enter();
        }
        
        //## statechart_method 
        public void nextFloorEnter() {
        }
        
        //## statechart_method 
        public void openingDoor_enter() {
            pushNullConfig();
            state_3_subState = openingDoor;
            state_3_active = openingDoor;
            openingDoorEnter();
        }
        
        //## statechart_method 
        public void openingDoorEnter() {
            //#[ state ROOT.activeLift.state_3.openingDoor.(Entry) 
            openDoor();
            itsScheduleApplication.removeFloor(currentFloor);
            //#]
        }
        
        //## statechart_method 
        public void alarmMode_enter() {
            mode_subState = alarmMode;
            state_4_active = alarmMode;
            alarmModeEnter();
        }
        
        //## statechart_method 
        public void processingNextScheduledActionEnter() {
        }
        
        //## statechart_method 
        public int mode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = state_4_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void state_4_entDef() {
            state_4_enter();
            state_4EntDef();
        }
        
        //## statechart_method 
        public int rootState_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void activated_entDef() {
            activated_enter();
        }
        
        //## statechart_method 
        public int idleTakedoorClosed() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            idle_exit();
            idle_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void alarmMode_exit() {
            alarmModeExit();
        }
        
        //## statechart_method 
        public int normalMode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(alarmTriggered.alarmTriggered_CargoLiftSystem_id))
                {
                    res = normalModeTakealarmTriggered();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = mode_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int activated_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(liftIsDown.liftIsDown_CargoLiftSystem_id))
                {
                    res = activatedTakeliftIsDown();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void changingDirection_entDef() {
            changingDirection_enter();
        }
        
        //## statechart_method 
        public void moving_exit() {
            popNullConfig();
            movingExit();
        }
        
        //## statechart_method 
        public void moving_entDef() {
            moving_enter();
        }
        
        //## statechart_method 
        public int movingToNextFloor_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(reachedNextFloor.reachedNextFloor_CargoLiftSystem_id))
                {
                    res = movingToNextFloorTakereachedNextFloor();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void nextFloor_exit() {
            popNullConfig();
            nextFloorExit();
        }
        
        //## statechart_method 
        public int openingDoorTakedoorClosed() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 18 
            if(hasMoreFloorsToProcess())
                {
                    openingDoor_exit();
                    processingNextScheduledAction_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    openingDoor_exit();
                    idle_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void openingDoor_exit() {
            popNullConfig();
            openingDoorExit();
        }
        
        //## statechart_method 
        public void openingDoorExit() {
        }
        
        //## statechart_method 
        public void rootState_enter() {
            rootStateEnter();
        }
        
        //## statechart_method 
        public void rootStateEnter() {
        }
        
        //## statechart_method 
        public void processingNextScheduledAction_exit() {
            popNullConfig();
            processingNextScheduledActionExit();
        }
        
        //## statechart_method 
        public void processingNextScheduledAction_enter() {
            pushNullConfig();
            state_3_subState = processingNextScheduledAction;
            state_3_active = processingNextScheduledAction;
            processingNextScheduledActionEnter();
        }
        
        //## statechart_method 
        public int alarmModeTakealarmFinished() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            alarmMode_exit();
            normalMode_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void alarmModeExit() {
        }
        
        //## statechart_method 
        public void normalMode_enter() {
            mode_subState = normalMode;
            state_4_active = normalMode;
            normalModeEnter();
        }
        
        //## statechart_method 
        public void activatedExit() {
        }
        
        //## statechart_method 
        public int idleTakeliftRequest() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            idle_exit();
            moving_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int movingTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 13 
            if(hasCallForThisFloor())
                {
                    moving_exit();
                    openingDoor_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    moving_exit();
                    movingToNextFloor_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void nextFloor_entDef() {
            nextFloor_enter();
        }
        
        //## statechart_method 
        public int openingDoor_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = openingDoorTakeNull();
                }
            else if(event.isTypeOf(doorClosed.doorClosed_CargoLiftSystem_id))
                {
                    res = openingDoorTakedoorClosed();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int processingNextScheduledAction_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = processingNextScheduledActionTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void processingNextScheduledAction_entDef() {
            processingNextScheduledAction_enter();
        }
        
        //## statechart_method 
        public void state_3Exit() {
        }
        
        //## statechart_method 
        public void mode_entDef() {
            mode_enter();
            
            normalMode_entDef();
        }
        
        //## statechart_method 
        public void activeLiftEnter() {
        }
        
        //## statechart_method 
        public void activeLift_entDef() {
            activeLift_enter();
            state_3_entDef();
            state_4_entDef();
        }
        
        //## statechart_method 
        public void idle_enter() {
            state_3_subState = idle;
            state_3_active = idle;
            idleEnter();
        }
        
        //## statechart_method 
        public int alarmModeTakeinAlarmMode() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            alarmMode_exit();
            alarmMode_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void normalModeEnter() {
        }
        
        //## statechart_method 
        public void state_4Exit() {
        }
        
        //## statechart_method 
        public void rootStateEntDef() {
            activeLift_entDef();
        }
        
        //## statechart_method 
        public void processingNextScheduledActionExit() {
        }
        
        //## statechart_method 
        public void normalMode_entDef() {
            normalMode_enter();
        }
        
        //## statechart_method 
        public int changingDirectionTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            changingDirection_exit();
            moving_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int idle_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(liftRequest.liftRequest_CargoLiftSystem_id))
                {
                    res = idleTakeliftRequest();
                }
            else if(event.isTypeOf(doorClosed.doorClosed_CargoLiftSystem_id))
                {
                    res = idleTakedoorClosed();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int openingDoorTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            openingDoor_exit();
            openingDoor_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_3_enter() {
            state_3Enter();
        }
        
        //## statechart_method 
        public int normalModeTakealarmTriggered() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            normalMode_exit();
            alarmMode_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void mode_enter() {
            state_4_subState = mode;
            modeEnter();
        }
        
        //## statechart_method 
        public void activeLift_exit() {
            state_3_exit();
            state_4_exit();
            activeLiftExit();
        }
        
        //## statechart_method 
        public void changingDirectionEnter() {
        }
        
        //## statechart_method 
        public void nextFloor_enter() {
            pushNullConfig();
            state_3_subState = nextFloor;
            state_3_active = nextFloor;
            nextFloorEnter();
        }
        
        //## statechart_method 
        public int alarmMode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(alarmFinished.alarmFinished_CargoLiftSystem_id))
                {
                    res = alarmModeTakealarmFinished();
                }
            else if(event.isTypeOf(inAlarmMode.inAlarmMode_CargoLiftSystem_id))
                {
                    res = alarmModeTakeinAlarmMode();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = mode_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void normalMode_exit() {
            normalModeExit();
        }
        
        //## statechart_method 
        public void modeEnter() {
        }
        
        //## statechart_method 
        public int state_4_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void state_4_enter() {
            state_4Enter();
        }
        
        //## statechart_method 
        public void state_4Enter() {
        }
        
        //## statechart_method 
        public void activeLift_enter() {
            rootState_subState = activeLift;
            rootState_active = activeLift;
            activeLiftEnter();
        }
        
        //## statechart_method 
        public void rootStateExit() {
        }
        
        //## statechart_method 
        public void idleExit() {
        }
        
        //## statechart_method 
        public int moving_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = movingTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int movingToNextFloorTakereachedNextFloor() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            movingToNextFloor_exit();
            nextFloor_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void activated_enter() {
            state_3_subState = activated;
            state_3_active = activated;
            activatedEnter();
        }
        
        //## statechart_method 
        public int nextFloorTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 15 
            if(hasCallForThisFloor())
                {
                    nextFloor_exit();
                    openingDoor_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    nextFloor_exit();
                    movingToNextFloor_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void openingDoor_entDef() {
            openingDoor_enter();
        }
        
        //## statechart_method 
        public int processingNextScheduledActionTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 22 
            if(needToChangeDirection())
                {
                    processingNextScheduledAction_exit();
                    changingDirection_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    processingNextScheduledAction_exit();
                    moving_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void state_3Enter() {
        }
        
    }
}
/*********************************************************************
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Lift.java
*********************************************************************/

